In [1]:
import numpy as np
import pandas as pd
import os,sys
from pathlib import Path
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 18})
plt.rcParams['figure.figsize'] = (10, 6)
cwd = os.getcwd() #grabs current working directory
carbonfolder = str(Path().resolve().parent.parent.parent / 'PV_ICE' / 'baselines' / 'SupportingMaterial' / 'CarbonIntensities')
supportmatfolder = str(Path().resolve().parent.parent.parent / 'PV_ICE' / 'baselines' / 'SupportingMaterial')

Manufacturing by country¶

We appear to only have mine production data, which may not be a good representation of where silver is refined, but lacking other data, we will use country market share of mining data from the World Silver Survey and USGS.

In [2]:
ag_WSS2023_raw = pd.read_csv(os.path.join(carbonfolder, 'input-worldsilversurvey2023-silverminebycountry.csv'),
                                     index_col=0)#, usecols=lambda x: x not in skipcols)
ag_WSS2014_raw = pd.read_csv(os.path.join(carbonfolder, 'input-worldsilversurvey2014-silverminebycountry.csv'),
                                     index_col=0)#, usecols=lambda x: x not in skipcols)
ag_USGS_raw = pd.read_csv(os.path.join(carbonfolder, 'input-USGS-silverminebycountry.csv'),
                                     index_col=0)#, usecols=lambda x: x not in skipcols)
In [3]:
ag_WSS = pd.concat([ag_WSS2014_raw,ag_WSS2023_raw]).groupby(['Mine Production Million Ounces']).sum()
ag_WSS_kg = ag_WSS*0.02835*1e6 #convert to kg
ag_WSS_kg = ag_WSS_kg.rename_axis('MineProduction_[kg]')
ag_WSS_kg = ag_WSS_kg.fillna(0)

ag_USGS = ag_USGS_raw.interpolate()
In [4]:
ag_USGS_raw.interpolate()
Out[4]:
Algeria Argentina Armenia Australia Azerbaijan Bolivia Botswana Brazil Bulgaria Burma ... Tajikistan Tanzania Thailand Tunisia Turkey UnitedKingdom USA Uzbekistan Zambia Zimbabwe
MineProduction_[kg]
1998 2000 36000 0 1474000 0 404000 0.000000 34000 24000 3000.0 ... 5000 0 0.0 3000.0 110000 0.000000e+00 2060000 85000 8000.0 7000
1999 1000 74000 0 1720000 0 422000 0.000000 42000 25000 4000.0 ... 5000 1000 0.0 3700.0 100000 0.000000e+00 1950000 89000 4940.0 5000
2000 1000 78000 0 2060000 0 434000 0.000000 41000 25000 1804.0 ... 5000 1000 0.0 3650.0 110000 0.000000e+00 1980000 90000 4560.0 4000
2001 2000 153000 0 2100000 0 408000 0.000000 46000 25000 1500.0 ... 5000 7000 0.0 4000.0 100000 0.000000e+00 1740000 80000 5000.0 3000
2002 1000 126000 6000 2077000 0 450000 0.000000 33000 609000 1000.0 ... 5000 8000 0.0 3000.0 79000 0.000000e+00 1350000 80000 0.0 2000
2003 1000 134000 4000 1868000 0 465000 0.000000 31000 50000 1000.0 ... 5000 8000 0.0 3000.0 95000 0.000000e+00 1240000 80000 0.0 1000
2004 500 172000 4000 2224000 0 407000 0.000000 35000 50000 1000.0 ... 5000 13000 0.0 2000.0 73000 0.000000e+00 1250000 80000 0.0 3000
2005 1000 175000 4000 2417000 0 419000 0.000000 38000 50000 2000.0 ... 5000 13000 0.0 4000.0 80000 0.000000e+00 1230000 83000 0.0 3000
2006 0 245124 40434 1727000 0 472208 0.000000 30000 65000 684.0 ... 3110 14906 0.0 4000.0 167340 1.160000e+06 0 62207 0.0 1000
2007 0 255567 37324 1879000 0 524989 0.000000 36000 55000 500.0 ... 3110 12381 0.0 4000.0 198000 1.280000e+06 0 77759 0.0 600
2008 0 355596 40434 1926000 0 1113764 0.000000 35500 55000 0.0 ... 3110 10388 0.0 4000.0 294000 1.250000e+06 0 74648 0.0 500
2009 0 415235 52876 1635000 0 1325700 0.000000 35000 55000 500.0 ... 3110 8231 0.0 4000.0 351600 1.250000e+06 0 52876 0.0 500
2010 0 723238 68428 1879000 1500 1259388 0.000000 69000 27538 500.0 ... 2651 12470 17083.0 4000.0 363520 5.000000e+02 1280000 59097 10000.0 500
2011 0 747449 25277 1725000 1217 1213586 0.000000 71600 32144 500.0 ... 1764 10399 19456.0 4000.0 246500 5.310000e+02 1120000 60000 10000.0 550
2012 0 799277 22200 1727000 626 1205804 8670.000000 71900 46523 500.0 ... 1767 11227 31147.0 4000.0 193890 5.000000e+02 1060000 60000 10000.0 600
2013 0 843600 19458 1839783 2051 1287200 22597.000000 72500 55637 500.0 ... 3000 11014 31021.0 4000.0 189600 5.000000e+02 1040000 64000 10000.0 600
2014 16 989950 19333 1847000 239 1398163 22228.000000 36700 50200 500.0 ... 3000 14493 31046.0 4000.0 183880 4.383333e+02 1180000 230000 10000.0 1297
2015 20 1175760 14346 1430000 133 1306098 2801.000000 41300 37955 500.0 ... 4000 15569 21047.0 4000.0 190550 3.766667e+02 1090000 230000 10000.0 1212
2016 20 1055700 16000 1418000 320 1353202 4064.666667 38800 52526 500.0 ... 3000 17984 35954.0 4000.0 376640 3.150000e+02 1150000 230000 10000.0 1463
2017 25 997961 15500 1120000 3429 1196416 5328.333333 86000 53053 500.0 ... 4300 10911 35954.0 4000.0 151490 2.533333e+02 1030000 220000 10000.0 1480
2018 26 1023768 19500 1254000 3229 1191024 6592.000000 71000 41315 500.0 ... 6300 12262 35954.0 4000.0 197320 1.916667e+02 934000 224000 10000.0 1542
2019 20 1071000 22800 1325000 3820 1152628 7855.666667 66000 35145 500.0 ... 10800 12607 35954.0 4000.0 242000 1.300000e+02 981000 219200 10000.0 1493
2020 12 767087 23100 1343000 4310 1153100 9119.333333 68000 32760 500.0 ... 11600 13187 35954.0 4000.0 98300 1.240000e+02 1080000 237600 10000.0 1522
2021 12 720000 22200 1363000 3860 1291817 10383.000000 80000 31816 500.0 ... 11100 13000 35954.0 4000.0 98296 2.500000e+02 1020000 237000 10000.0 1500

24 rows × 79 columns

In [5]:
#compare the values of the two dataframes
common = ag_USGS.index.intersection(ag_WSS_kg.index)
common_yrs = ag_USGS.columns.intersection(ag_WSS_kg.columns)

ag_USGS.loc[common,common_yrs]/ag_WSS_kg.loc[common,common_yrs]
Out[5]:
Argentina Armenia Australia Bolivia Botswana Brazil Bulgaria Canada Chile China ... Spain Sweden Tajikistan Tanzania Thailand Turkey USA Uzbekistan Zambia Zimbabwe
MineProduction_[kg]
2004 1.318917 0.108533 1.097174 1.025447 0.000000 4.115226 2.939447 1.133666 1.097752 1.367401 ... inf 1.099478 1.763668 1.146384 0.000000 0.643739 1.096809 1.485194 0.000000 1.058201
2005 1.028807 0.117578 1.101495 1.154652 0.000000 4.467960 2.519526 1.159277 1.114734 1.304488 ... 0.881834 1.201620 inf 1.146384 0.000000 0.542667 1.106792 1.394138 0.000000 1.058201
2006 1.271522 1.097110 1.095631 1.095814 0.000000 3.527337 3.821282 1.124931 1.100778 1.208310 ... 0.835626 1.100037 inf 1.314462 0.000000 0.983774 0.000000 1.044881 0.000000 0.352734
2007 1.112927 1.097119 1.097329 1.095747 0.000000 3.174603 4.850088 1.136739 1.096399 1.200985 ... 1.199295 1.013171 inf 1.455732 0.000000 0.931217 0.000000 1.097129 0.000000 0.211640
2008 1.172249 1.097110 1.097520 1.097380 0.000000 3.130511 4.850088 1.193897 1.098887 1.164687 ... 1.216931 1.112791 inf 1.221399 0.000000 1.026769 0.000000 1.548874 0.000000 0.176367
2009 0.818253 1.165697 1.100610 1.097697 0.000000 3.086420 3.880071 1.141224 1.097878 1.178488 ... 1.234568 1.074419 inf 0.967784 0.000000 0.992169 0.000000 1.097126 0.000000 0.176367
2010 1.099614 1.419815 1.097329 1.083484 0.000000 6.084656 2.428395 1.133889 1.106971 1.305040 ... 0.025195 1.158270 inf 1.099647 0.860821 1.042486 1.106615 1.097132 0.881834 0.176367
2011 1.166595 0.371502 1.096334 1.097622 0.000000 6.313933 2.267654 1.246997 1.113631 1.272042 ... 0.294372 0.922651 0.622222 0.917019 0.857848 0.934934 1.097394 1.113896 0.881834 0.194004
2012 1.160214 0.301180 1.097606 1.071354 1.529101 6.340388 2.735038 1.134797 1.138778 1.216323 ... 0.250823 1.113404 0.623280 0.990035 0.915550 0.936870 1.096474 1.113896 0.881834 0.211640
2013 1.118670 0.298413 1.096205 1.096712 0.996340 2.557319 inf 1.145013 1.143570 1.224562 ... 0.176367 1.114854 0.176367 inf 0.911846 1.028897 1.091795 0.382626 inf inf
2014 1.179692 0.284142 1.096800 1.144267 0.980071 1.176848 inf 1.095331 1.104427 1.057608 ... 0.875613 1.062675 0.105820 inf 0.995543 1.013448 1.098221 1.375064 inf inf
2015 1.139369 0.202413 1.096542 1.096916 0.988007 0.910494 inf 1.099699 1.103133 1.004891 ... 0.687503 1.070926 0.128267 inf 0.927998 1.018385 1.098513 1.375064 inf inf
2016 1.167338 0.235156 1.096878 1.097287 1.433745 0.547443 inf 1.170711 1.136496 1.016617 ... 0.613733 1.107754 0.081400 inf 0.975553 1.982890 1.096334 1.375064 inf inf
2017 1.205529 0.210284 1.097394 1.096146 inf 1.083396 inf 1.022094 1.151258 1.091232 ... 1.535208 1.110849 0.101117 inf 12.682187 1.090523 1.094324 1.315278 inf inf
2018 1.168665 0.343915 1.097588 1.096904 inf 1.088874 inf 1.171793 1.208322 1.091370 ... 1.486756 1.108348 0.148148 inf 12.682187 1.480881 1.105548 1.339192 inf inf
2019 1.148261 0.335097 1.097118 1.095878 inf 1.058201 inf 0.913737 1.209009 1.089204 ... 1.301772 1.038058 0.272109 inf 12.682187 2.667549 1.102012 1.267528 inf inf
2020 1.127406 0.313390 1.101678 1.360325 inf 1.090268 inf 1.219040 1.172649 1.096857 ... 1.307400 1.055382 0.272781 inf 12.682187 0.866843 1.201743 1.330310 inf inf
2021 0.910280 0.313228 1.123308 1.097994 0.610406 1.226900 inf 1.259864 1.097880 1.093818 ... 1.201907 1.187857 0.261023 inf 12.682187 0.630406 1.103645 1.229381 inf inf

18 rows × 56 columns

So it looks like on average, USGS is reporting higher than the world silver survey, but it is really inconsistent. MAybe I will take both dataframes through the process, and see if they come out with the same countries that matter.

In [6]:
#USGS country market share
ag_USGS['SUM'] = ag_USGS.sum(axis=1)
ag_USGS_mrktshr = ag_USGS.div(ag_USGS['SUM'], axis=0)*100
#ag_USGS_mrktshr
In [7]:
ag_WSS_kg['SUM'] = ag_WSS_kg.sum(axis=1)
ag_WSS_mrktshr = ag_WSS_kg.div(ag_WSS_kg['SUM'], axis=0)*100
#ag_WSS_mrktshr
In [17]:
#take the median of each country and only consider the big ones.
country_market_medians_USGS = ag_USGS_mrktshr.median()
country_market_medians_USGS.loc[country_market_medians_USGS>=1]
Out[17]:
Argentina       2.354488
Australia       7.739948
Bolivia         4.491565
Canada          2.858926
Chile           6.085946
China          12.942929
Indonesia       1.307193
Kazakhstan      3.250129
Mexico         15.907177
Morocco         1.054667
Peru           14.830289
Poland          5.343839
Russia          5.294344
Sweden          1.552606
USA             4.280695
SUM           100.000000
dtype: float64
In [20]:
country_market_medians_WSS = ag_WSS_mrktshr.median()
country_market_medians_WSS.loc[country_market_medians_WSS>=1].sort_index()
Out[20]:
Argentina       3.092509
Australia       7.002602
Bolivia         4.708602
Canada          2.353915
Chile           5.417219
China          13.346900
India           1.265673
Indonesia       1.157943
Kazakhstan      2.330783
Mexico         21.018025
Morocco         1.059603
Peru           16.041735
Poland          5.076142
Russia          5.099338
SUM           100.000000
Sweden          1.439746
USA             4.296565
dtype: float64

Great, they have nearly the same top countries that matter. WSS adds India, so we'll choose the world silver survey.

We will only consider these countries, the rest will be summed into "World". Then take the new marketshare of each, and print to csv.

In [28]:
important_countries = pd.Series(country_market_medians_WSS.loc[country_market_medians_WSS>=1].sort_index().index.values)
important_countries
Out[28]:
0      Argentina
1      Australia
2        Bolivia
3         Canada
4          Chile
5          China
6          India
7      Indonesia
8     Kazakhstan
9         Mexico
10       Morocco
11          Peru
12        Poland
13        Russia
14           SUM
15        Sweden
16           USA
dtype: object
In [56]:
ag_WSS_kg_subset = ag_WSS_kg.loc[:,important_countries]
ag_WSS_kg_importantcountries = ag_WSS_kg_subset.drop('SUM', axis=1)
ag_WSS_kg_importantcountries['World'] = ag_WSS_kg_subset.loc[:,'SUM']-ag_WSS_kg_importantcountries.sum(axis=1)
ag_WSS_bycountrymarketshare = ag_WSS_kg_importantcountries.loc[:,:].div(ag_WSS_kg_subset.loc[:,'SUM'], axis=0)*100
ag_WSS_bycountrymarketshare
Out[56]:
Argentina Australia Bolivia Canada Chile China India Indonesia Kazakhstan Mexico Morocco Peru Poland Russia Sweden USA World
MineProduction_[kg]
2004 0.749918 11.656342 2.282361 6.781872 7.124226 10.303228 0.554288 1.402022 3.684382 13.465928 1.173785 16.041735 7.140528 4.939680 1.532442 6.553635 4.613629
2005 0.938380 12.105099 2.001877 5.348764 6.928370 10.572412 0.516109 1.548327 4.081952 14.560525 1.235533 16.046293 6.334063 5.082890 1.423209 6.130748 5.145449
2006 1.057543 8.646967 2.363919 4.852255 8.009331 11.804044 0.917574 1.228616 3.981337 14.852255 1.181960 17.278383 6.298600 4.867807 1.337481 5.707621 5.614308
2007 1.216216 9.069069 2.537538 4.009009 9.354354 11.906907 0.855856 1.291291 3.423423 15.135135 1.036036 16.906907 5.945946 4.399399 1.411411 6.081081 5.420420
2008 1.566389 9.061631 5.240814 3.147416 6.602254 12.413995 0.995462 1.171132 2.957107 15.239350 1.141853 17.318109 5.709267 5.328649 1.229688 5.270092 5.606793
2009 2.507354 7.339964 5.967222 2.731475 5.855162 12.158566 0.868469 1.078582 2.759490 16.010646 1.246673 17.313349 5.490965 5.911192 1.218658 5.631041 5.911192
2010 3.092509 8.051186 5.465209 2.452679 5.465209 12.609971 1.093042 0.893095 2.346041 18.901626 1.319648 15.595841 5.011997 4.905359 1.226340 5.438550 6.131698
2011 2.993377 7.350993 5.165563 2.476821 5.417219 13.589404 0.993377 0.794702 2.331126 20.344371 1.059603 14.543046 5.403974 5.099338 1.205298 4.768212 6.463576
2012 3.066633 7.004038 5.010096 2.688036 4.669359 14.273094 1.501767 0.567895 2.208481 21.744069 0.946492 14.121656 5.212014 5.678950 1.236749 4.303382 5.767289
2013 3.146440 7.002602 4.897090 2.353915 4.447599 13.969718 1.265673 0.922640 2.519517 22.131535 0.875325 14.549326 4.589543 5.251952 1.277502 3.974450 6.825172
2014 3.355629 6.733930 4.886067 1.723161 5.690965 13.490534 0.952273 0.793561 2.051922 21.018025 0.884253 14.284095 4.353248 5.226165 1.439746 4.296565 8.819862
2015 4.057971 5.128205 4.682274 1.326644 5.362319 13.277592 1.337793 1.103679 1.794872 21.415831 1.003344 15.117057 4.370123 5.696767 1.761427 3.901895 8.662207
2016 3.546020 5.068920 4.835482 1.289462 5.180080 13.483771 1.556247 1.200534 1.934193 19.375278 1.111605 16.929747 4.546465 5.180080 1.823032 4.112939 8.826145
2017 3.381195 4.168597 4.458082 1.470588 4.678092 13.478462 1.956925 1.157943 2.188513 21.653543 1.192682 17.948124 4.828624 4.863363 1.794812 3.844372 6.936082
2018 3.637434 4.743967 4.508534 1.389052 4.708652 13.019423 2.495586 1.212478 2.330783 22.895821 0.824014 17.245438 4.814597 5.073573 1.765745 3.507946 5.826957
2019 3.938233 5.099354 4.440986 1.615992 4.572660 13.346900 2.441944 0.909744 2.034953 22.480249 0.957625 16.171894 4.836007 5.350730 1.723725 3.758678 6.320326
2020 3.063960 5.489595 3.817184 1.200051 6.051321 13.979318 2.757564 1.123452 2.221371 23.005234 1.161752 12.970765 5.030001 5.374697 1.710711 4.046981 6.996042
2021 3.372009 5.172831 5.015712 1.099831 4.979454 13.645153 2.683104 1.232777 1.812908 23.688663 0.966884 13.959391 5.076142 4.713561 1.679961 3.940053 6.961566
2022 3.759581 4.684268 4.708602 1.058523 5.097944 13.602628 2.713225 1.387030 1.800706 24.236525 0.973354 13.018615 5.158778 5.000608 1.800706 3.942085 7.056820
In [57]:
ag_WSS_bycountrymarketshare.to_csv(os.path.join(carbonfolder, 'output-silver-MFGingByCountry.csv'))

Possible future improvement - use USGS pre-2004, and WSS starting in 2004